package ex2_2;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.concurrent.LinkedBlockingQueue;

class ReceivedData extends Thread {
	File input;
	LinkedBlockingQueue<String> inputData;

	public ReceivedData(File input, LinkedBlockingQueue<String> inputData) {
		this.input = input;
		this.inputData = inputData;
	}

	public void run() {
		BufferedReader in;
		try {
			in = new BufferedReader(new InputStreamReader(new FileInputStream(input)));
			String line;
			while ((line = in.readLine()) != null) {
				inputData.put(line);
			}
			inputData.put("END");
			in.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
